const path = require('path');
const htmlWebpackPlugin = require('html-webpack-plugin')
    // const OpenBrowserPlugin = require('open-browser-webpack-plugin'); //默认浏览器不能自动打开，需要下载插件


module.exports = {
    entry: path.join(__dirname, './src/main'),
    output: {
        path: path.join(__dirname, './dist/'),
        filename: 'bundle.js'
    },
    plugins: [
        new htmlWebpackPlugin({
            template: path.join(__dirname, './src/index.html'),
            filename: 'index.html'
        }),
        // new OpenBrowserPlugin({ url: 'http://localhost:3000', browser: 'iexplor' })
    ],
    module: {
        rules: [
            { test: /\.css$/, use: ['style-loader', 'css-loader'] },
            { test: /\.less$/, use: ['style-loader', 'css-loader', 'less-loader'] },
            { test: /\.scss$/, use: ['style-loader', 'css-loader', 'sass-loader'] },
            { test: /\.(png|gif|jpg|bmp|jpeg)$/, use: 'url-loader' },
            { test: /\.(ttf|svg|woff|woff2|eot)$/, use: 'url-loader' },
            { test: /\.js$/, use: 'babel-loader', exclude: /node_modules/ },
            //必须添加exclude配出包
            { test: /\.vue$/, use: 'vue-loader' },
        ]
    }
}